package com.yyds.blackmagic.service.impl;
import com.yyds.blackmagic.entity.Article;
import com.yyds.blackmagic.mapper.ArticleMapper;
import com.yyds.blackmagic.service.ArticleService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class ArticleServiceImpl implements ArticleService {
    @Resource
    private ArticleMapper articleMapper;
    @Override
    public List<Article> findAll() {
        return articleMapper.findAll();
    }

    @Override
    public List<Article> findAllByTime() {
        return articleMapper.findAllByTime();
    }

    @Override
    public Article findOneByTitle(String article_title) {
        return articleMapper.findOne(article_title);
    }

    @Override
    public Article findOneByContent(String article_content_md) {
        return articleMapper.findOne2(article_content_md);
    }

    @Override
    public Article findOneById(int id) {
        return articleMapper.findOne3(id);
    }

    @Override
    public Article addArticle(Article article) {
        articleMapper.add(article);
        return article;
    }

    @Override
    public Article updateArticle(Article article) {
        articleMapper.update(article);
        return article;
    }

    @Override
    public boolean delArticle(int id) {
        int i = articleMapper.del(id);
        if (i>-1){
            return true;
        }else return false;
    }
}
